package com.example.myzhugezhaofang.adapter;

import android.content.Context;
import android.graphics.Color;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.example.mvplibrary.adapter.BaseAdapter;
import com.example.mvplibrary.adapter.BaseViewHolder;
import com.example.myzhugezhaofang.R;
import com.example.myzhugezhaofang.bean.HighOpinionBean;

import java.util.List;

public class HighOpinionAdapter extends BaseAdapter<HighOpinionBean.ListBean> {

    public HighOpinionAdapter(List<HighOpinionBean.ListBean> datas, Context context, int layoutId) {
        super(datas, context, layoutId);
    }

    @Override
    protected void bindData(BaseViewHolder holder, HighOpinionBean.ListBean listBean, int position) {
        List<String> tags = listBean.getTags();

        TextView text11 = holder.getView(R.id.tv_item_highOpinion_11);
        TextView text12 = holder.getView(R.id.tv_item_highOpinion_12);
        TextView text2 = holder.getView(R.id.tv_item_highOpinion_2);
        TextView text4 = holder.getView(R.id.tv_item_highOpinion_4);
        ImageView image = holder.getView(R.id.iv_item_highOpinion);
        RecyclerView recyclerView = holder.getView(R.id.rv_item_tag_highOpinion_3);

        LinearLayoutManager manager = new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(manager);
        TagAdapter tagAdapter = new TagAdapter(context, tags);
        recyclerView.setAdapter(tagAdapter);

        text11.setText(listBean.getName());
        text12.setText(listBean.getCate_status().getText());
        String color = listBean.getCate_status().getColor();
        int i = Color.parseColor(color);
        text12.setBackgroundColor(i);

        text2.setText(listBean.getRegion() + " / 开盘时间： " + listBean.getKpdate());
        text4.setText(listBean.getPrice() + listBean.getPrice_unit());
        Glide.with(context).load(listBean.getThumb()).into(image);
    }
}


